package org.dromara.learning_xq.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.dromara.learning_xq.entity.AsJobManagement;
import org.dromara.learning_xq.mapper.AsJobManagementMapper;
import org.dromara.learning_xq.service.AsJobManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AsJobManagementServiceimpl extends ServiceImpl<AsJobManagementMapper, AsJobManagement> implements AsJobManagementService {


    @Autowired
    private AsJobManagementMapper asJobManagementMapper;

    @Override
    public List<AsJobManagement> selverAsJobManagement() {
        // 查询并返回所有的 AsJobManagement 记录
        return asJobManagementMapper.selectList(null);
    }

    /**
     * 根据条件查询作业管理信息
     * 该方法通过传入的AsJobManagement对象作为查询条件，根据对象的非空属性进行数据库查询
     *
     * @param asJobManagement 作为查询条件的作业管理对象，其非空属性将作为查询的依据
     * @return 返回查询到的作业管理信息列表
     */
    @Override
    public List<AsJobManagement> selverAsJobManagementCondition(AsJobManagement asJobManagement) {
        QueryWrapper<AsJobManagement> queryWrapper = new QueryWrapper<>();

        // 构建查询条件，根据 asJobManagement 对象的非空属性进行查询
        if (asJobManagement != null) {
            if (asJobManagement.getScopeWork() != null) {
                queryWrapper.eq("scope_work", asJobManagement.getScopeWork());
            }
            if (asJobManagement.getChapterAffiliation() != null) {
                queryWrapper.eq("chapter_affiliation", asJobManagement.getChapterAffiliation());
            }
            if (asJobManagement.getBelongingSection() != null) {
                queryWrapper.eq("belonging_section", asJobManagement.getBelongingSection());
            }
            // 可以继续添加其他属性的条件
        }

        // 返回查询结果
        return asJobManagementMapper.selectList(queryWrapper);
    }


}
